<!-- 编辑账号 -->
<template>
  <div class="eidt-user">
    <div class="header">编辑管理员{{$route.params.uid}}</div>
    <el-form label-width="100px">
      <el-form-item label="uid">
        <el-input disabled :value="$route.params.uid"></el-input>
      </el-form-item>
      <el-form-item label="账号">
        <el-input :value="userData.account" v-model="userData.account"></el-input>
      </el-form-item>
      <el-form-item label="昵称">
        <el-input :value="userData.nickname" v-model="userData.nickname"></el-input>
      </el-form-item>
      <el-form-item label="手机号">
        <el-input :value="userData.phone" v-model="userData.phone"></el-input>
      </el-form-item>
      <el-form-item label="状态">
        <el-input :value="userData.status" v-model="userData.status"></el-input>
      </el-form-item>
      <el-form-item label="角色">
        <el-input :value="userData.user_role" v-model="userData.user_role"></el-input>
      </el-form-item>
      <el-form-item>
        <router-link to="/dashboard/system/user">
          <el-button>返回</el-button>
        </router-link>
        <el-button @click="updateUser" type="primary">更新</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import systemUser from "@/mixins/systemUser";
export default {
  mixins: [systemUser],
  computed: {
    // ...mapGetters('systemuser',[
    //   'getCurrentUser'
    // ])
  },

  data() {
    return {
      userData: []
    };
  },
  created() {
    this.$http.getUserById({ uid: this.$route.params.uid }).then(res => {
      // console.log(res)
      if (res && res.data.code == 200) {
        this.userData = res.data.data;
      }
    });
  },
  methods: {
    updateUser() {
      this.$http.updateSystemUser(this.userData).then(res => {
        // console.log('更新账号成功',res)
        let tips = res.data.msg;
        if (res.data.code == 200) {
          this.$message({
            type: "success",
            message: tips
          });
          this.load();
          this.$router.push("/dashboard/system/user");
        }
      });
    }
  }
};
</script>

<style scoped lang="less">
.eidt-user {
  background: #fff;
  .header {
    padding: 15px 0 15px 20px;
    border-bottom: 1px solid #eee;
  }
  .el-form {
    padding: 20px;
    .el-input {
      width: 80%;
    }
  }
}
</style>
